package com.kopcheski.hqlgen;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.part.ViewPart;

public class View extends ViewPart {
	public static final String ID = "hqlgen.view";

	private Label label;
	private ModifyListener comboModifyListener = new ComboModifyListener();

	@Override
	public void createPartControl(Composite composite) {
		this.label = new Label(composite, 0);
		this.label.setText("Classe: ");

		Combo combo = new Combo(composite, SWT.DROP_DOWN);
		combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
		combo.setItems( new String[] {"Entity1", "Entity2"});

		combo.addModifyListener(this.comboModifyListener);
	}

	@Override
	public void setFocus() {
		this.label.setFocus();
	}

}

class ComboModifyListener implements ModifyListener {

	@Override
	public void modifyText(ModifyEvent event) {
		Composite composite = ((Combo) event.getSource()).getParent();
		new Button(composite, SWT.CHECK).setText("Check 1");
		new Button(composite, SWT.CHECK).setText("Check 2");
		new Button(composite, SWT.CHECK).setText("Check 3");
	}

}